// @flow
import React from 'react'
import styles from './BodePage.css'
import Bode from 'components/Bode'
import type { Location } from 'react-router'

type Props = {
  location: Location,
}
type State = {}

const { search } = location
const paramsString = search.substring(1)
const searchParams = new URLSearchParams(paramsString)

class SpecificGram extends React.Component {
  props: Props
  state: State
  constructor (props: Object) {
    super(props)
    this.state = {}
  }
  componentWillMount () {
    const token = searchParams.get('token')
    if (token) {
      localStorage.setItem('asset_token', token)
    }
  }
  render () {
    const requestType = searchParams.get('requestType')
    const deviceId = searchParams.get('deviceId')
    const deviceNo = searchParams.get('deviceNo')
    return (
      <div className={styles['main']}>
        <Bode {...{
          requestType,
          // historyCond: deviceFileCondition.historyCond,
          deviceData: {
            id: deviceId,
            deviceNo: deviceNo
          }
        }} />
      </div>
    )
  }
}
export default SpecificGram
